import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from "../views/Login";
import UserIndex from "../views/user/UserIndex";
import CommodityManagement from "../views/admin/CommodityManagement"
import AdminIndex from "../views/admin/AdminIndex";
import OrderManagement from "../views/admin/OrderManagement";
import CommodityAdd from "../views/admin/CommodityAdd";
import UserManagement from "../views/admin/UserManagement";
import CommodityShow from "../views/user/CommodityShow";
import UserOrder from "../views/user/UserOrder";
import UserShopCar from "../views/user/UserShopCar";
import UserInformation from "../views/user/UserInformation";

Vue.use(VueRouter)

const routes = [
  {
    path:'/login',
    name:'Login',
    component: Login
  },
  {
    path: '/userIndex',
    name:'商城首页',
    component: UserIndex,
    redirect: 'commodityShow',
    user:true,
    children: [
      {
        path: '/CommodityShow',
        name:'商品展示',
        component: CommodityShow
      }
    ]
  },
  {
    path: '/userIndex2',
    name:'用户信息',
    component: UserIndex,
    redirect: 'commodityShow',
    user:true,
    children: [
      {
        path: '/userOrder',
        name:'用户订单',
        component: UserOrder
      },
      {
        path:'/userShopCar',
        name:'用户购物车',
        component: UserShopCar
      },
      {
        path: '/userInformation',
        name:'个人信息',
        component: UserInformation
      }
    ]
  },
  {
    path: '/adminIndex1',
    name:'商品管理',
    component: AdminIndex,
    redirect:'/commodityManagement',
    admin:true,
    children:[
      {
        path: '/commodityManagement',
        name: '库存总览',
        component:CommodityManagement
      },
      {
        path: '/commodityAdd',
        name: '库存添加',
        component:CommodityAdd
      }
    ]
  },{
    path: '/adminIndex2',
    name:'订单管理',
    component: AdminIndex,
    redirect:'/commodityManagement',
    admin:true,
    children:[
      {
        path: '/orderManagement',
        name: '订单总览',
        component:OrderManagement
      }
    ]
  },
  {
    path: '/adminIndex3',
    name:'用户管理',
    component: AdminIndex,
    redirect:'/commodityManagement',
    admin:true,
    children:[
      {
        path: '/userManagement',
        name: '用户总览',
        component:UserManagement
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
